﻿#include "widget.h"
#include "ui_widget.h"

#include <QDebug>
#include <QFontDatabase>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    this->setWindowTitle("智能家居"); //设置窗口标题

    // 圆角图像
    QPixmap avatar(":/icon/avatar.png");
    avatar = ImageTools::getRoundedPixmap(avatar,33,66,66);
    ui->avatar->setPixmap(avatar);

    // 轮播图
     ui->slider_panel->resize(590,330);
     ui->slider_panel->move(0,0);
     ui->slider_panel->setStyleSheet("background:transparent;border:0;");
     ImageCarousel *carousel = new ImageCarousel(ui->slider_panel);

     QList<QPixmap> imageList;
     imageList << QPixmap(":/images/1.png") << QPixmap(":/images/3.png") << QPixmap(":/images/2.png") << QPixmap(":/images/5.png");
     carousel->setImageList(imageList);
     carousel->startCarousel();


     // 对time单独使用字体
     // 添加字体路径
    int fontid = QFontDatabase::addApplicationFont(":/fonts/D-DINEXP.TTF");
    QStringList font_list = QFontDatabase::applicationFontFamilies(fontid);

    if(!font_list.isEmpty())
    {
        QFont f(font_list[0]);
        ui->time->setFont(f);
    }
}

Widget::~Widget()
{
    delete ui;
}



